package com.gzl.testhibernate.annotation;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;

public class HibUtil { 
	private static SessionFactory factory; 
	 
	private HibUtil(){ 
	} 
	static { 
		Configuration configuration = new AnnotationConfiguration(); 
		configuration.configure(); 
		factory = configuration.buildSessionFactory(); 
	} 
	public static SessionFactory getFactory() { 
		return factory; 
	} 
	public static Session getSession(){ 
		return factory.openSession(); 
	} 
}
